package java3_29;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;


/**
 *
 1:一件商品生产日期是2017/7/12,保质期5年，算出失效日期
 */
public class Homework1 {
    public static void main(String[] args) throws ParseException {

        String time = "2017/7/12";
        SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
        Date p = format.parse(time);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(p);
        int year = 5;
        int days = (year * 365)+2;
        calendar.add(Calendar.DAY_OF_YEAR, days);
        Date o = calendar.getTime();
        String str = format.format(o);
        System.out.println("失效日期：" + str);
    }
}
